Usually (not always, but true for the examples of multiplication of real numbers and multiplication of square matrices), a binary operation that is called some variant on ‘multiplication’ is the multiplicative operation of some [ring](https://en.wikipedia.org/wiki/Ring_(mathematics)). That's the closest thing to a rigorous definition of multiplication ‘in general’ that you're likely to find. The ring axioms don't require multiplication to be commutative; they only require that it is associative, that it has an identity element (usually called ‘1’ or ‘unit’ or some variation), and that it distributes over whatever is being called ‘addition’.
Occasionally conflated with the concept of ‘multiplication’ is the concept of ‘product’, which often carries slightly different connotations. Products usually generalize the idea of forming pairs of things—the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of two sets $A$ and $B$, for example, is written $A \times B$ and means the set of all pairs where the first entry in the pair is any element of $A$ and the second entry is any element of $B$. The connection to real number products should be evident; for finite sets, the cardinality of (number of elements in) the Cartesian product of two sets is the real number product of the cardinalities of each of the sets. But the Cartesian product is not, strictly speaking, an operation that can be used as the multiplicative operation in a ring, because it doesn't have a unit—you can take the Cartesian product of a single-element set with any other set and get a set with the same cardinality, but it will be a different set (a set of pairs instead of a set of not-pairs). The generalization of this concept is perhaps best formalized by the [category theoretical product](https://en.wikipedia.org/wiki/Product_(category_theory)), if you dare venture into those woods.
Finally, there are lots of examples of things called products or multiplication in mathematics not because they conform rigorously to one of the above two concepts, but because they involve or are closely related to something that does. Multiplying a vector by a scalar, for example, is not a ring multiplication or a product-like operation, but since it involves doing ring multiplication between the scalar and the vector elements, it gets called multiplication itself. This is how most things called ‘multiplication’ actually got their names, since many of them predate formal ring theory and category theory.
If you are an aspiring mathematician, the thing to remember when encountering a new operation called ‘whatever multiplication’ is that it is its own thing, and you need to pay attention to its definition and properties and not carry too many preconceptions from anything else called ‘multiplication’. It might be associative or even commutative... but it might not. It might have an identity, but it might not. It might be a way of pairing things together, but it might not. It might involve a more familiar form of multiplication in its definition, but it might not. The axioms and logic of higher mathematics are (ideally) rigorous, but the *terminology* often isn't. Naming things is hard, and changing the names of things is harder!