The average aircraft carrier length is 1000 feet, and the runway for a really small airport is around a mile long. How do they take off and land?
the planes are basically thrown down the runway with a steam-powered catapult that boosts them up to flying speed by the time they reach its end. For landing, they use a tail hook on the plane that catches a cable or series of cables stretched across the runway; the cable(s) then bring the plane to a quick halt.
The stresses imposed on the airframe by all this violent action are great, requiring very strong construction. The hazards presented by carrier operations are great too; a malfunction of the catapult which causes the plane to not reach flying speed will throw the plane off the bow right into the path of the ship, which then overruns the plane. And if the tail hook misses all the cables, the plane is at risk of running off the runway and falling into the water.
There are multiple different systems in place. The most widely-used ones are:
CATOBAR (catapult-assisted takeoff but arrested landing): the airplane spools up its engine(s) to full thrust while being held in place by a restraint system, then gets literally catapulted off the deck with a sled that is attached to the nose wheel gear and "slings" the airplane forward and accelerates it to takeoff speed. For landing, the airplane extends a tail hook that catches a steel wire on the deck which "pulls" the airplane to a stop.
STOL (short takeoff and landing): some airplanes are capable of normal takeoff and landing on the runway lengths provided by an aircraft carrier. This is mostly no longer in use, but it was the way things worked in WW I and WW II. The world records for STOL airplanes at the moment are about 10 feet for takeoff and under 10 feet for landing.
VTOL (vertical takeoff and landing): some airplanes are able to take off and land vertically. Some examples are the McDonnell Douglas AV-8B Harrier II "Jump Jet" and the F-35B variant of the Lockheed Martin F-35 Lightning II.
STOVL (short takeoff / vertical landing): taking off vertically uses a lot of fuel and limits the weight of the airplane (meaning they cannot take as many weapons with them), therefore it is more efficient to have a short takeoff roll and take off with at least some forward speed.
Ski Jump: at the end of the deck, the very end of the runway is curved upward, this gives the airplane additional upward momentum and accelerates it upwards into the air. Typically used for STOVL airplanes. The most well-known examples are the British aircraft carriers of the last decades.
In all of these different modes, the aircraft carrier can always do two things that an airport cannot do:
The carrier turns directly into the wind (or in case of an angled flight deck at such an angle that the runway points directly into the wind). That means, an airplane never has to worry about taking off with a crosswind or tailwind, it will always have a headwind, which increases the airspeed.
The carrier accelerates to its highest sustainable speed. So, even if there is no wind, the airplane already has some forward velocity relative to the airflow.