Hanger and hangar are homonyms. They sound exactly alike. They cannot, however, be used interchangeably.
If you are a person who hangs things, you are a hanger, much like if you paint things you are a painter. A writer writes. A singer sings.
A hanger is also a thing that hangs clothes.
A hangar is the name of a place where you can park your plane (or spaceship as the case may be). The word comes from the French word for “shed.”
The way I was taught to remember which word to use was to think that “plane” has an “a” in it and “hangar” has an “a” at the end part.
Both “clothes” and “hanger” have an “e” in the end part.