Baking soda acts as an abrasive. This means that baking soda literally cleans one’s teeth by scrubbing them. Baking soda is really only good at removing surface stains that have not been on your teeth for very long. If the stains are deeper and older then other measures will probably have to be taken.
Where as baking soda is a natural substance that has multiple uses in multiple arenas there are products on the market that are made specifically for whitening teeth and a dentist should be consulted when attempting to remove older more stubborn stains that baking soda will not take care of.