Light does not need a medium.
Mechanical waves need a medium with inertia and a restoring force.
For longer waves on a water surface it is gravity that provides the driving force to a flat surface. The motion of water below the surface is not so easy to describe mathematically.
Sound waves in air or water are pressure waves where the elasticity provides the restoring force. These are longitudinal waves. Transverse waves cannot exist in a fluid because there is no restoring force for a shearing deformation. Solids have an elastic shear modulus so there will also be transverse waves.
Mathematically one often ends up with the wave equation, a differential equation that for mechanical waves is derived from Newton's law $F = ma.$ The solutions are then functions of position and time that can be written as $$f(x,t) = f(x-vt),$$ which propagate with a velocity $v.$