Context: Equation 1 requires substituting A for B.
Does this mean all "A" in equation 1 is replaced with "B" or vice versa?
It's probably a matter of looking at the original equation. Because the 'for' could be interpreted differently by different folks.
I would take "substituting A for B" to mean replacing B's with A's. It would be more clear if written as "substituting A's with B's."
In the end, you're going to have two equations, one with A's and one with B's. So, whatever you have on hand now, the sentence means create the other.
Whilst I agree with SamC's answer, subject to David M's comment, I also agree, contrary to other comments, that 'substituting A for B' is entirely ambiguous.
'For', in this context, could mean both 'in place of', as well as 'in favour of'.