These valves (more generally called the atrioventricular valves) are there to prevent back flow of blood from the ventricles to the atria when the ventricles contract. The same thing happens in both of them:
As the ventricles contract, the pressure in the ventricles increases. This, due to the fact that the valves are one way valves, causes the tricuspid and mitral valves to clamp shut. Then, as the ventricles keep on contracting, and blood is pushed upwards, is it prevented from travelling back into the atria and must travel out of the semilunar valves, through to the aorta and pulmonary artery and out of the hear.