It depends why they are doing it. Young males often do this. It could be immaturity, jealousy, mind games.
However, do bear in mind that a true friend does not always agree with you. A true friend tells you in private when he or she believes that you are wrong about something and this is especially important when your friend believes that your thoughts or opinions could lead you into danger or harm.
You should ask your friend why he or she feels the need to contradict you, privately, not in front of others.
Friends do not always have exactly the same thoughts and opinions about every single thing and sometimes it is very important that they do not.