Saying "the compiler allocates memory" may not be factually accurate in the literal sense, but it's a metaphor that's suggestive in the right way.
What really happens is that the compiler creates a program that allocates its own memory. Except that it isn't the program that allocates memory, but the OS.
So what really happens is that the compiler creates a program that describes its memory requirements and the OS takes that description and uses it to allocate memory. Except that the OS is a program, and programs don't actually do anything, they describe a computation that is performed by the CPU. Except that the CPU is really just a complicated electronic circuit, not an anthropomorphised little homonculus.
But it makes sense to think of programs and compilers and CPUs as little people who live inside a computer, not because they actually are, but because that's a metaphor that fits the human brain well.
Some metaphors work well for describing things on one level of abstraction, but don't work as well on another level. If you think on the level of the compiler, it makes sense to describe the act of generating code that will result in memory being allocated when the program that is being compiled is actually run as "allocating memory". It's close enough that when we're thinking about how a compiler works, we have the right idea, and it's not so long-winded that we forget what we were doing. If we try to use that metaphor on the level of the compiled program running, it's misleading in a weird sort of way, which is what you noticed.