It's very simple: The JIT (Just In Time) compiler, which is part of the JVM, converts
Java bytecode to native machine code at runtime. At that moment it can detect the exact brand and model of the CPU that the program it is running on, so it can generate native machine code that is optimal for that particular CPU.
Note that both AMD and Intel x86-compatible CPUs implement the same instruction set, with minor differences. Newer processors often have enhancements, such as SSE instructions, etc.
When you use a traditional ahead-of-time compiler to compile for example C or C++ source code to native machine code, then the compiler can't make use of CPU-model specific enhancements, at least not if you want the resulting executable to be useable for most people. Suppose you'd compile the code with Intel Core-family specific enhanced native machine code, then it will not run on older CPUs that don't have those extra instructions.
An advantage of having a JIT is that it can (in principle) generate machine code with those extra instructions, since it knows exactly what the target CPU is at runtime - so it can optimize the code very specifically for that CPU.