Hi Lizzy,
I think you are talking about alternate nostril breathing, the so called Nadi Shodhana pranayama. It is a breathing technique which is done either the way you described (imagining the breath going through one and then the other nostril) or the nostrils are physically closed one after the other with your hand (a special mudra - hand gesture is used for this).
The main purpose of regulating the breath through the nostrils is to balance the so called ida and pingala nadis - the energy channels of our subtle body. The ida nadi is linked to the left nostril and represents the feminine, receptive, cool energy, whereas the pingala nadi is linked to the right nostril and represents the masculine, active, heat energy. They are also linked to the opposite brain hemispheres. During this pranayama technique, the opposite energies are harmonised and the brain hemispheres are balanced.
It is a safe practice if done correctly. The breath must not be forced or rushed. It is also not a good thing to do if one of the nostril or both are blocked.
Before you start doing it at home by yourself, I would suggest to make sure that you have learned the technique properly under the guidance of a teacher. Enjoy! I love this technique too!
