How does the phrase "Is something the matter?" make sense?
What you're observing is a phenonmenon called lexicalization. Consider the following sentence:
What is the matter?
Here the speaker assumes that some problem exists and asks what that problem is. "The matter" means "the matter of concern"; i.e., the thing that we should be worried about. This makes perfect sense on every level of analysis.
But through the repeated use of this expression or some similar one, the phrase "the matter" has become lexicalized into an expression of its own, carrying the sense of "something that we should be worried about". The word "the" here cannot be analyzed on its own. That would be like if you said that you were going to say something, and I asked you where you were going. Here the word "going" is relieved of its usual semantic duties in order to work a side gig as part of a lexicalized aspect marker.
Is this lexicalized usage of "the matter" logical? Not especially, but langauge doesn't need to be logical—not even formal, educated, standard language. If it intelligibly communicates its intended meaning, then, by definition, it makes sense.
The reason you're confused is because you're trying to analyze an idiom, a set phrase. the matter is a set phrase, not decomposable into its constituents. Your examples are all correct and idiomatic.
Almost always, there is a logical explanation to the actual wording of an idiom. Often lost in the mists of time. I'd guess that 'Is something the matter?' is a shortened form of an expression like the logical 'Is something I can help with the matter causing you concern?' And one can research 'kick the bucket' on the web.
Sometimes, the meaning of an idiom may be opaque but the literal meaning of the words quite obvious, with standard syntax being used
kick the bucket
Sometimes, the meaning may be fairly transparent (deducible) and the literal meaning of the words quite obvious, with standard syntax being used
ship of the desert
I won't attempt to give an example of each of the 8 possible permutations, or throw in how flexible (ships of the desert? handsome ships of the desert?...) individual idioms might be, but here are some which depart from the use of standard grammar:
all of a sudden
all the same
at daggers drawn
beyond compare
curiouser and curiouser
flatter to deceive
long time, no see
on the up and up
the bigger, the better
trip the light fantastic
Some may be rather more old fashioned than others, but their use seems to cause no worries for most anglophones. Some are more transparent than others (I've seen arguments about the meaning of 'flatter to deceive').