Assembly language is usually specific to just one specific microprocessor. However, even the latest PC processors are backward compatible with older machine code. So the Intel X86 series is an exception as are others. Even machine code isn't always machine dependent.
Some higher level programming languages such as Python or Java are interpreted. Java is compiled into virtual machine code and it runs on a virtual Java machine which makes it compatible with any Java platform. Python is a little more restricted and will only run where there is an interpreter that is compatible. These are actually two examples of programming languages that never get compiled into machine code. So not all languages end up as machine code when they are run.
Other mid to high level languages such as C, C++, Pascal, Fortran and others are usually compiled to machine code. They are also somewhat platform independent as long as compilers exist on the different platforms. The up side of compilers is the machine code usually runs faster than interpreted programs.
There is a special class of programming languages which may run as interpreted languages or compiled into machine code. Where both compilers and interpreters exist for a language, you can have it both ways. Some versions of BASIC may be run as an interpreted language and compiled.
Last is emulation. With an emulator, you can run machine code for another computer just the same as you could run it on the original target computer. Some classics such as the Commodore 64 have emulators available and this allows you to run 6502 machine code on a PC. Similarly, computers such as the TRS-80 and Atari computers also have emulators available for them with Z-80 and 6800 processor emulation respectively. They are more than just microprocessor emulation since they reproduce the entire computer with most or all of it's original function.
Perhaps the thing to remember is none of the programming languages are really machine dependent or machine independent. A lot depends on what tools may be available for the computer.
Shadow Wolf