Difference between "matter" and "problem"

In my exercise book, there is a multiple - choice question like that:
That so many students failed the test is no laughing …
A. Thing
B. Matter
C. Affair
D. Problem
The correct answer is B.
I wonder why we don’t choose D as well. Can you explain the difference between “matter” and “problem”?
Thank you in advance.

‘No laughing matter’ is idiomatic.

I’ve got another sentence:

The ___ (matter/problem) is that there are not enough hospital beds to guarantee proper treatment.

The correct answer is “problem”. Why?

As it must be so. Matter is something more general than problem which indicates some bad thing.

Because ‘matter’ in this sentence would merely mean ‘topic’.