How many rectangles or triangles.
To have a rectangle, you need 2 horizontal lines and 2 vertical lines. So for your given picture, there are $5\choose 2$ choices for two vertical lines. Also $4\choose 2$ choices for horizontal lines. So there are ${5 \choose 2}\times{4\choose2}$ rectangles in total.
The strategy is to find a way to categorize the things you want to count. Various problems will require various tricks, but you can gain experience by trying to solve them by your own.