Text this: Dynamics of subnanosecond electron beam formation in gas-filled and vacuum diodes