Action potential and sodium channels
The key to understanding this is to digest the fact that there are two gates blocking a normal sodium channel. These gates are called the activation gate (on the extracellular side) and the inactivation gate on the intracellular side. Both of these together, or any one of these alone, if closed, can block the sodium current from entering the cell.   


In the resting state, the activation gate is closed and the inactivation gate is open. There is no influx of sodium. Owing to a neurotransmitter release, there is depolarization of the plasma membrane around the channel. As soon as the potential reaches a fixed threshold value, there is a change in the conformation of the sodium channel. The voltage is sensed by a biophysical voltage sensor, a part of the channel.  
At the threshold potential, both the gates respond by reversing their state. But owing to the biophysical structure, the response of the activation gate is faster than the response of the inactivation gate. What happens is that the activation gate quickly opens allowing the influx of sodium ions, generating the action potential. The inactivation gate is closing but before it closes, the activation gate has been open for some time and the action potential is already fired due to considerable depolarization. 
After some time, the inactivation gate also closes completely, blocking the sodium influx. By this time, the potential is at the peak of the action potential, the potassium channels have opened, and the re-polarisation phase begins. Here the inactivation gate is closed, thouh the activation gate is still open above the threshold potential. As the potential dips below the threshold, again the gates reverse their states but they respond with different speeds. First, the activation gate closes while the inactivation gate is still closed, and then the inactivation gate opens. In this way, during repolarisation, no sodium influx occurs since atleast one of the two gates is always closed.  


I hope I answered your questions. Here are further links to understand this in greater detail. 


Wikipedia 
Mechanism of sodium channel inactivation
Basics of Voltage-Gated ion channels in Neuroscience
Mechanism of Voltage gated Channels in general(Detailed)



A more technical and biophysically accurate version of the diagram.