There are several valves in the heart that help to control the movement of blood between chambers and/or into the large vessels associated with the heart. The former are the atrioventricular (AV) valves and the latter are the semilunar valves.
There are two (2) AV valves in a typical human heart. One between the right atrium and right ventricle (the tricuspid valve) and the other between the left atrium and the left ventricle (the bicuspid or mitral valve). Their locations between the atria and the ventricles are responsible for the name atrioventricular valves.
The valves are not only attached to the openings of the ventricles from the atria, they are also attached to chordae tendineae, string-like structures that attach the valves to the papillary muscles of the walls of the ventricles.
When the atria contract, the decreased size and corresponding increased pressure in the chambers pushes the blood that they contained into the ventricles, through the AV valves. The ventricles then contract with the goal of sending the blood into either the pulmonary artery (right side) or the aorta (left side). This can successfully occur because when the ventricles contract and the blood is pushed against both the AV valves (leading back into the atria) and the semilunar valves (leading to the large vessels) the pressure closes the AV valves (preventing backflow of the blood into the atria) and opens the semilunar valves so that the blood enters the vessels mentioned previously.