Rear wheel is not locking when I am braking
If you have mechanical brakes the most likely answer is that you brakes simply need adjusting or the pads need replacing.

Cable stretch and pad wear result in having to pull the lever further to move the pads onto the rim or rotor, eventually the lever hits the bar before sufficient pressure is exerted by the pads for effective braking.

If you have hydraulic brakes things are different as they are self-adjusting. In this case you most likely have air bubbles in the fluid and the brakes need to be bled. 

If your brakes are adjusted properly, pad or rotor contamination could be the problem. Although it seems unlikely that both brakes got contaminated (unless you did something to both brakes that contaminated them). 

There are plenty of videos and articles available that will show you how to adjust brakes. They are not hard to find.