The horse pulls the cart, not the cart the horse. The proverb means that we should not get things back to front, but should deal with them in their right order. To invite all your relatives and friends to your wedding before you have arranged things with the vicar is to put the cart before the horse.