Visualizing electron rearrangement in space and time during the transition from a molecule to atoms