Males inherit Y DNA from their father and pass it on to their male children. Males also inherit mitochorndial DNA (mtDNA) from their mother, but they do not pass it on to their children.
Females inherit mtDNA from their mother and pass it on to their children.
Other types of DNA are passed down through generations and are also useful for genealogy.
DNA test results tell you that you share a common ancestor with someone else who has tested with the same company. it does this because you provide to the company all or parts of your documented family tree, including the most distant ancestor that you have documented. There are websites that let you compare your information with those who have tested with other companies. Tools are also available to help you compare information and identify relatives.
Genetic genealogy is a supplement and check on traditional genealogy. It can verify suspected relationships and also tell you where to look further.
About 15% of DNA tests reveal an NPE, a "Non-Parental Event". It means you are not descended from who you thought or were told you were. The NPE might be distant or recent, and the result of an adoption, unrecorded death or divorce followed by a remarriage, or other incidents related to human nature.