It's rather simple. Military (not commercial) vessels break down over time. A component will break randomly, usually a big one like a sensor or engine, but never things like fuel storage or crew quarters. Every tick (5 days?) has a chance for failure. The failure rate can be lowered using Maintenance Spaces and their various sizes, which makes the chance of breakdown significantly lower. Each repair (using damage control menu) uses up maintenance supplies. Each maintenance space provides a little supply, but supply storage adds a ton more. Maintenance supplies are also needed to repair a ship after battle, if the armor/shields let any damage leak in.
Any ship that can fit into a hangar will automatically use the mothership's supplies, and can repair armor (ships outside of a hangar cannot repair armor).
Most players tend to leave their warships around a planet, where it draws a small upkeep cost of materials, and give the ship itself 1-2 years of expected maintenance life, only deploying them to do something. Some very small ships, sometimes fighters and gunships, can go without any maintenance, although this leaves them very vulnerable to breakdown and might need a small carrier ship to retrieve them.
In a recent battle, two enemy fighters rammed my gunboat (the gunboat was 20HS and had 6 layers of armor) and destroyed the engine. My carrier picked it up and promptly restored it to full using onboard supplies. My sensor ship also took a few hits, and repaired its internal sensors with supplies, though the armor had to be left damaged.