No single exercise is mandatory. Squats and deadlifts are efficient because they load a great deal of muscle heavily in one movement, but the underlying patterns matter more than the specific lift. If a barbell squat hurts, a well-loaded alternative squat pattern will still build strength.
What your body responds to is a heavily loaded knee-dominant movement and a heavily loaded hip-dominant movement, plus pushing, pulling, and carrying. The barbell versions are simply the most loadable and the easiest to measure. Swap the tool, keep the pattern.
Barbell squats and deadlifts remain the most load-efficient options available, so alternatives usually need more sets or more exercises to produce the same total stimulus. If your goal is competitive powerlifting, the specific lifts are the sport and cannot be substituted.
Pick the variation you can load progressively, perform without pain, and repeat for months. That is the real requirement. Use the exercise library to find alternatives that match your equipment and any restrictions you are working around, and see a clinician about any movement that consistently causes pain.