Why do I get incorrect solutions $ x = 0 $ and $ x = 2 $ for $ x + 1 + \sqrt{4x + 1} = 0 $? Here is my incorrect attempt at solving
$$ x + 1 + \sqrt{4x + 1} = 0. $$
Subtracting $ \sqrt{4x + 1} $ from both sides,
$$ x + 1 = -\sqrt{4x + 1} $$
Squaring both sides,
$$ x^2 + 2x + 1 = 4x + 1 $$
Subtracting $ 4x + 1 $ from both sides,
$$ x^2 - 2x = 0 $$
We have obtained
$$ x(x - 2) = 0 $$
It has two solutions: $ x = 0 $ and $ x = 2 $.
But if we substitute $ x = 0 $ in LHS of the original equation we get
$$ x + 1 + \sqrt{4x + 1} = 1 + \sqrt{1} = 2 $$
If we substitute $ x = 2 $ in LHS of the original equation we get
$$ x + 1 + \sqrt{4x + 1} = 3 + \sqrt{9} = 6 $$
Apparently I have made a mistake in some step that has led to this contradiction. Which step is incorrect in my solution above? It must be the squaring step that changes the minus sign to positive sign.
But squaring both sides is an often used step in many equations. What rules I need to keep in mind while solving such equations so that I do not get incorrect solution after squaring both sides?

Trick question: there will not be any real-number solutions.  If the original equation, $ \  x + 1 + \sqrt{4x + 1} \  =  \ 0 \  $ is considered as a curve intersection equation, we would write $ \ \sqrt{4x + 1} \ = \ -x - 1 \ \   . $  The left side of the equation represents a square-root curve which resembles the "upper half" of a "horizontal" parabola $ \ ( y \ \ge \ 0 ) \ $ with its vertex at $ \ \left( -\frac14 \ , \ 0 \right) \ \ , $ since the domain of this function is $ \ x \ \ge \ -\frac14 \ \ . $  The line $ \ y \ = \ -x - 1 \ $ has the $ \ y-$intercept $ \ (0 \ , \ -1) \ $ and the $ \ x-$ intercept $ \ (-1 \ , \ 0) \ \ , $ so it passes "to the left" of the square-root curve's vertex and never enters the first quadrant.  Hence, there is no intersection of these curves, which means there is no real-number solution for our equation.

The act of squaring both sides of the equation to obtain $ \ 4x + 1 \ = \ (x + 1)^2 \ \ , $ however, produces a second equation which is consistent with this squared equation:  $ \ -\sqrt{4x + 1} \ = \ -x - 1 \ \   . $  Because this new square-root curve is on or "below" the $ \ x-$axis $ \ ( y \ \le \ 0 ) \ \ . $ it can intersect the line $ \ y \ = \ -x - 1 \ $ at the two points that you found:
$$ 4x \ + \ 1 \ \ = \ \ x^2 \ + \ 2x \ + \ 1 \ \ \Rightarrow \ \ x·(x - 2) \ \ = \ \ 0   $$ $$ \Rightarrow  \ \ x \ = \ 0 \ \ , \ \ y \ = \ -\sqrt{4·0 + 1} \ = \ -0 - 1 \   =   \ -1 \ \ \ ; \ \ \  $$
$$ \Rightarrow  \ \ x \ = \ 2 \ \ , \ \ y \ = \ -\sqrt{4·2 + 1} \ = \ -2 - 1 \   =   \ -3 \ \ .  $$
Because the "negative square-root" curve is not implied by our original equation, we must ignore both of these solutions.
There are no "hard-and-fast rules" for solving non-linear equations, since there are so many possibilities for the functions involved.  But it is generally a good idea to consider the properties of the functions you will be working with, and having at least a sketch of the graph for the situation can provide some insight.
[I thought it would be of interest to discuss this problem because it is a rare instance of an equation for which all of its solutions are "spurious".]
