I remember being initially confused by signs in Atwood machine calculations at school many (and I mean many) years ago. But then I sussed it out. Not sure if this will help or not but...
Here are 3 approaches you can use for problems like this. They all boil down to the same thing of course.
Method 1. Consistently use ‘upwards is positive’.
For the left mass: ##T – m_1g = m_1a_1##
For the right mass: ##T – m_2g = m_2a_2##
and then remember
##a_2=-a_1## (as already noted by
@Chestermiller)
Method 2. Take the direction of acceleration as locally positive (so each mass has the same positive acceleration).
For the rising left mass: ##T – m_1g = m_1a## (upwards is positive)
For the descending right mass: ##m_2g – T = m_2a## (downwards is positive)
Method 3 (for acceleration).
Realise the magnitude of acceleration is the same as that of a total mass of ##M = m_1+m_2## accelerated by a force, F, which is the difference in weights (##F = (m_2 – m_1)g##). Then use ##F=Ma##. That gives the acceleration very simply; then you can easily find tension if required.
Method 1 is the most general/rigorous and preferred for more complex problems. But Methods 2 and 3 are useful if you understand them well enough to use them appropriately.
[Minor edits only]