imagine a slope at an angle of say 30degrees(or theta) to the horizontal. you have a car on the slope moving downwards(not important). it has a weight perpendicular to the horizontal; and a contact force perpendicular to the slope, i.e. at 30degrees(or theta) to the horizontal. picture this.
now you want to break the weight into its 2 components: one will be perpendicular and the other will be parallel to the slope.
using simple mathematics the angle between the weight and the component of weight perpendicular to the slope(found below the slope) are the same. this component is the y component, while the other component, parallel to the slope, is the x component.
if you use the cosine of this angle, 30degrees(or theta), the closest component will be mg cos 30 (or mg cos theta). the component, farther, will be mg sin 30 (or mg sin theta).
now you can use the angle between the component parallel to the slope and the weight. this is equal to 60degrees (or 90 - theta).
if you use cosine of this angle, 60degrees (or 90 - theta), the closest component will be mg cos 60 (or mg cos (90 - theta)). the component, farther, will be mg sin 60 (or mg sin (90 - theta)).
you really need to visualize it to understand, i couldn't upload the diagram.
and i used weight as example. and this is a simple way to know which is sin and which is cos. the logic behind this is found by using trigonometrial reasoning i guess.