The heart follows a cycle of contraction (systole) and relaxation (diastole), like this:
whole heart diastole --> atria systole --> ventricular systole --> atria diastole, ventricular systole --> whole heart diastole
So how does this affect pressure? When is pressure high and low?
whole heart diastole ---> atria systole ---> ventricular systole ---> atria diastole, ventricular systole ---> Whole heart diastole
The underline shows that that section of the heart is at high pressure. So how does this affect the blood flow?
During whole heart diastole, the atria are filling with blood. Atria systole starts, so the high pressure pushes the blood through the atrio-ventricular valves (imagine squeezing a bottle with a sports cap), and the low pressure ventricals fill up. Next, the ventricals contract, which increases the pressure up in the ventricals, and pushes the blood out through the semi lunar valves into the pulmonary artery(right) and Aorta (left).
So why doesn't the blood flow backwards into the atria?
Well, at the start of ventricular systole, the atria are still in systole, which means the pressure there is also high. The AV valve is also a one way valve, so the blood takes the path of least resistance - out through the semi lunar valves. Once the blood has started flowing out, the atria begin to relax, and start filling up ready to enter whole heart diastole and start the cycle again.