Well… it doesn’t, strictly speaking.
After all, a marriage – when it’s been attempted to be celebrated properly, with all the attendant preparation and attention to detail – is presumed valid by the Church. The phrase you’ll hear, expressing this, is “marriage enjoys the favor of the law.”
So, the Church doesn’t need to determine whether a marriage is valid – if the attempt was there, in good faith, to make sure that it was valid at the time of the ceremony, then it’s presumed valid. Period.
But, if the marriage fails and one of the spouses asks the Church to investigate whether it was, in fact, valid – that is, s/he asks the Church to determine whether it was null or not – then the Church, who has the competency to regulate her own Sacraments, can investigate. Then, it makes a determination as to whether something essential was missing at the time of the ceremony, or if there was something standing in the way of a valid marriage at the time of the ceremony.
Marriage requires the consent of the spouses. If there were a lack of consent, or faulty consent, then the marriage can be declared null.
Marriage must be free from impediment. If there were an impediment present at the time of the ceremony (e.g., one of the spouses was not free to marry), then the marriage can be declared null.
For Catholics, marriage must be celebrated according to a prescribed form (i.e., in a Catholic church or chapel, by a priest or deacon). If this form was not followed, the marriage can be declared null.
If you want to read up on the particular issues which might cause a marriage to be declared null, I recommend Foster’s excellent book “Annulment: The Wedding that Was”.
As @PaulfromIowa mentions, there are (relatively rare) instances in which the Church may dissolve a marriage. In most cases, however, dissolution is not possible, but a case for nullity might be able to be made.
Does that help?