Valves in the heart and veins ensure unidirectional blood flow. In the heart, valves between atria and ventricles (atrioventricular valves) and at the exits of the ventricles (semilunar valves) prevent backflow. In veins, valves prevent blood from flowing backward, especially in the extremities where blood must travel against gravity to return to the heart.