Papillary muscles are conical muscle projections located in the ventricles of the heart that attach to the heart valves via chordae tendineae. They play a crucial role in preventing the inversion or prolapse of the valves during ventricular contraction, ensuring that blood flows in one direction and maintaining efficient heart function.