The British Armed Forces comprise the Royal Navy (RN), the army, and the Royal Air Force (RAF). The Royal Marines are treated as part of the Royal Navy for many purposes (unlike the USA, where the Marines are an entirely separate branch).
The Crimnal Justice and Public Order Act 1994, which reduced the age of consent from 18 to 16, also legalised sex involving men in the Armed Forces, but with the important proviso that it could still be treated as grounds for discharge from the Armed Forces. So although they were no longer committing a criminal offence, servciemen (and women) who were discovered to be gay could still lose their jobs.
In 1999, Duncan Lustig-Prean and others, having been discharged from their services for homosexuality, won a case in the European Court of Human Rights. Following this ruling, the Defence Secretary announced that homosexuality would no longer be treated as an offence under service discipline, and gay men and lesbians have since been entirely free to serve in the Armed Forces without having to conceal their orientation.