Measure words, or classifiers, are placed before nouns and any modifying adjectives. They are generally based on shape, size, amount, animacy, and/or function. Contrary to what some might believe, which classifier is used with a noun is often not strictly one classifier. As such, one should not liken classifiers to the gendered articles found in many languages such as German or Spanish.
When you do not know which classifier to use, guess 个, as native speakers often default to 个 in daily conversation unless the classifier is obvious.
Generally, people and intangible nouns (like ideas, processes, etc.) take 个. To signal respect to a person's job, that role (e.g. teacher) may take the classifier 位 (wei4).
Animals take 只 (zhi1) by default, but for large animals like cattle (牛) and sheep (羊), 头 ("head") is used. For dogs, either 条 or 只 is used depending on the speaker and region, and if the dog seems long in shape.