
Pretend we have a pulley with box of mass

and mass

hanging on either side.
)
To find acceleration

, and tension

, we have to find the equations of motion (fancy name for what the hell is going on for each particle, sort of like predicting what the boxes are going to do)
Now we need to have a reference direction, like how we have ‘left’ and ‘right’ ‘up’ and ‘down’, we need the direction to understand…
Now

and

components will not help in this case since the boxes are going in different directions. What we need to find is the direction where both are going. Pretend you were holding the two box things, if you let go of both, the heavier one will fall. So we will say the direction of motion is the direction which they move: up and around the pulley and back down the side with the heavier box.
Now what we do is apply

(how the box moves = mass x acceleration) to each box individually. Pretend the other box does not exist for now.
Now we can get an equation (1) from looking at the diagram. So according to our reference direction what do the boxes and forces do? For the smaller mass, m, it goes up. So tension is ‘helping’ it go up, so

is positive. Gravity is the opposite, trying to pull it down, so mg is negative. Using

, we get (1).
(1)
Remember the reference direction is up around the pulley down the big mass. So how is the gravity affecting the big mass? It is helping it go so

is positive. Tension is opposing it so

is negative. Adding these up gives mass x acceleration.
(2)

To find a, we can add (1) and (2) like simultaneous equations, rearrange and blah which gives:
g}{M+m})
To find

, we can substitute

back in (1) and then solve for

.
We can apply the sample principle to all cases, remembering that we must find a reference direction which is the easiest for calculating things. If you don't understand any of this, just ask.