Interplay between external inputs and recurrent dynamics during movement preparation and execution in a network model of motor cortex