The airplane doesn't know what the wind is...
A crusty old captain once asked me why on an out-and-back two leg flight with strong winds, it takes more total time than the same flight in calm winds.
I gave him the right answer but he corrected me saying that when flying into the wind, the wind blows against the blunt leading edge of the wing having a significant effect and when flying in a tail wind the wind blows on the sharp trailing edge and therefore has a lesser effect. So you don't gain back what you lost in the headwind.
He also explained why one leg of a V formation of migrating geese is invariably longer than the other.