teeter-totter perspective
This is something I have seen when dealing with polynomials too and it confuses me a bit. How do you know when it is okay to switch items around? To me, it seems like you can do anything to get the answer and it causes me pause because without know when you can move things around I may get the wrong answer. What is the rule on this?


You seem to be asking a very general and interesting question M. Holmes. Offering you another perspective.
An equation is a math "statement" with an "=" sign separating two "expressions". The equal sign means that the numerical weight of the quantity of each expression is the same; it is then said that the "equation is balanced" and that the statement is "true". If that were not the case then the equation would be declared "unequal", "unbalanced" and "false", a daunting denunciation, no?. 1 =1 is true and balanced, 1 = 2 is false and unbalanced.
The four fundamental operations of math are addition, subtraction, multiplication, and division each of these "operations" can be applied to an equation but you must apply them to both side of the equation in order for the equation to remain true and balanced.
For example you can 1 to both side of 1=1 and get 1+1 = 1+1 => 2 = 2, a fair and balanced reporting of the news.
You can can subtract 1 from both sides: 1=1 and get 1-1 = 1-1 => 0=0, fair and balanced
You can can multiply both sides by some number "x": 1=1 and get 1*x = 1*x => x=x, fair and balanced
You can divide both sides by some number "x": 1=1 and get 1(1/x) = 1(1/x) =>1/ x=1/x, fair and balanced BUT ...
only if you publicly announce that x cannot be zero, dividing by zero is "undefined", i.e has no meaning.
So you cannot "do anything" to get the answer (hey, where are your ethics), in fact, you can do only a very few things. Think of an equation as a balance scale, to keep the scale balanced you must add, subtract, multiply, or divide the weight on each pan equally or the balance and thus the truthfulness of the equation is lost.
Final note, besides the four fundamental operations, other operations may be applied to an equation (like the square root operator, or the Log operator), but as always they must be applied equally to both sides of the equation (both expressions), also, each new operation probably comes with restrictions (like the division operation disallowing zero) which must be minded (hate that but what are you going to do?).
hmmm ... in retrospect I may have missed the point of your question, if so sorry.
If p=2l+2w is balanced then
p -2w = 2I +2w -2w => p -2w = 2I is balanced
If p -2w = 2I is balanced then
p -2w -p = 2I-p -2w = 2I-p is balanced
If -2w = 2I-p is balanced then
-2w(1/-2) = (2I-p)(1/-2) => w = -(2I-p)/2 or w = (p-2I)/2, when you distrbute the (-) = (-1)
Checking tip: Find a set of numbers that balance the original equation, oddball numbers that are unlikely to cancel one another out (are incommensurate with one another) , like
I = 1.123, w = 2.2123, so p = 2I + 2w = 2(1.123)+2(2.123) = 6.492, p = 6.492
checking to see if these number still work in the final equation:
w = (p-2I)/2 ,
2.2123 =? (6.492-2*1.123)/2
2.2123 = 2.2123 Hooray !!!! (lights, bells)
If the result had been negative then one would have go back to the middle of the chain of the statements to start closing in on where the imbalance had occurred.