For example, on the Falcon Heavy, the two side cores detached from the first stage but how are they attached and what mechanism is used to detach them?
Pneumatic "pushers" (rather than traditional explosive pyrotechnics used by most rockets) are used to separate the boosters on the Falcon Heavy. There's probably some electrically operated, large mechanical latches holding them together beforehand.
By activating the pushers at the top of the booster before the bottom, the booster is tilted away from the core stage, which allows the aerodynamic force of the airstream to help push the booster away. (There's not much air at that altitude but it's going really fast.)
In most other rocket designs, explosive bolts are used for separation, but these produce debris (if used in orbit) and could potentially cause some damage to a reusable rocket (and would need to be replaced in any case). In many cases (e.g. the US space shuttle), small solid rocket modules are additionally used to rapidly push the booster away after the initial separation.
If you watch the video where the stages separate, you see the bottom two frames showing the side boosters, but the top frame flips over to the view of the pusher arms that fold back to the stage. Following SpaceX philosophy, they do not get thrown away, they fold back to be reused on the next mission.
Around 32:20 it gets interesting. First you see the booster attach points in the top frame.
Then it pushes it away. You can actually see the thinner actuators sticking out in these next two images.
Then finally the arms fold upwards, with the actuator really obviously sticking out.