The government has confirmed when both of the Royal Navy’s aircraft carriers are due to end their service.