NNokey,
Texas Holdem takes into consideration the best 5 cards.
So, yes you absolutely do count the second pair, and if both players have the same two pairs, then you would go down to the 5th card kicker.
Same goes for a flush, you would consider all 5 cards, with the higher cards winning the hand.
With your final scenario, it would be a split pot, because both players have the identical 5 card hand.
Hope that helps!