A cause of action would be a fact or facts which allows you the right to file an action against another person in order to get money, property, or the enforcement of some right (usually through an injunction). It also refers to the legal theory which forms the basis of the lawsuit.
While it is difficult to draw a clear distinction, the merits of the case can be distinguished from a cause of action as follows (just an example):
We have a contract and you do not hold up your end of the bargain. The fact that you did not do what the contract says you must do provides me the cause of action to file a lawsuit. During the trial, you demonstrate an affirmative defense showing you were forced into the contract under duress. The court, in deciding the case on its merits, or applying the legal principles of contract law, holds that the contract was therefore not enforceable (or there was no contract because one cannot be made under duress). You win, I lose and the case was decided on the merits.
However, if the case was dismissed for lack of jurisdiction or if you or I won on some procedural grounds, the case would have been dismissed or decided, but not "on its merits."