A geometric approach to constrained mechanical systems, symmetries and inverse problems