when and how is the machine language (binary stream) mapped to an existing instruction?
The actual binary machine code instruction set, and/or the sub-fields that compose the instruction set, are usually encoded in look-up tables (software arrays), or switch/case statements.  After parsing the human-readable text into tokens, numerical forms of these tokens can then be used to index into the lookup tables for the binary encodings.  The binary subfields, and offsets perhaps derived later, can then be "assembled" into binary machine code instructions by concatenation.

The very first assemblers were mostly women (job title "computer") who did this look-up manually.  (reference: history of the Eniac and Mark I, and the history book "When Computers were Human", by Grier).

On the other end, in the CPU hardware, there's usually an instruction register (or many for parallel execution models) followed by a decoder (or several), which (perhaps pipelined in layers) converts bit-fields into control signals, often a vast number.  Older computer were sometimes implemented using microcode, where another semi-hidden processor does the decoding of the visible machine code in software (hard-coded or pre-loaded vertical or horizontal microcode, 2 layers on some CPUs, such as the 68000).