The two blocks shown start from rest. The horizontal plane and the pulley are frictionless, and the pulley is assumed to be of negligible mass. Determine the acceleration of each block and the tension in each cord.

In the solution they used the displacement made by both sections of the string $x_A = 2(x_B)$ and then derived until you get the acceleration relationship of $a_A = 2(a_B)$.
Some books say we can relate the lengths of each wire and make the total length constant so like $x_A + 2(x_B) = L$
then derive until the acceleration relationship of $a_A + 2a_B = 0$ and $a_A = -2a_B$, but by using this we're getting opposite signs. Which one should I use?
The answer to your question lies in the fact that acceleration is a vector, not a scalar, meaning that your reference frame is just as important. In the first case, it appears that the right-handed direction is considered as positive, since the body accelerates in that direction.
On the other hand, the second solution methods assumes it to be the other way round, and then obtains a negative acceleration. Always clearly state the directions of the coordinate system you are taking as reference when solving such problems.
Also, note here that the total length of the rope has been written as a scalar quantity, and so you should keep this in mind when solving the problem. As the body A accelerates towards the right, the length of the rope available for it decreases, while the length of the rope available to body B increases (and B goes down by an equivalent 50% of the length A moves by)