By analysing lunar samples from NASA's Apollo missions, researchers calculated exactly when – and why – the moon was once covered with magma