1. She lived on the second floor.

Here we have used "the" before the word "second".

2. "Your mother is a better cook than mine," he said, taking a second bite.

Here "a" has been used before "second". I could not understand it.

Could anybody explain it?

Think of which article ("the" or "a") you would use were the word "second" omitted in each case. The articles in these examples do not refer to the word "second", but rather to the nouns they are modifying. The speakers are essentially referring to "the floor" and "a bite". In both cases "second" is an adjective, and articles never refer to adjectives.
hanuman_2000Could anybody explain it?
second has nothing to do with it. You're talking about the floor and a bite. In the first case the floor is named the second floor. In the second case, the bite is not named the second bite. We name the floors of a building; we don't name each bite of food that we take. Which floor we are talking about may be very important; which bite we take is not important.