As Caitlin explains it to Stein:
A quantum splicer, a fission device designed to bombard your atoms with as much energy as they experience inside the particle accelerator explosion. - Flash S1E13
This device basically can cause or reverse the results of the particle accelerator explosion which happened to Stein and Raymond, allowing them to merge and separate as needed.
We see many different abilities that people receive from the particle accelerator explosion, some of them are circumstantial or environmental (Weather Wizard gets power over weather because he was in a storm at the time). Presumably because Raymond was in the accelerator, his atoms got scattered, and then found a compatible host with Stein to create the entity Firestorm.
If you are asking for a scientific explanation, this is science fiction, please check your science at the door.
how is the "merging" of Firestorm explained in-universe?