In my CS courses we often use Big-O notation to denote the complexity of a certain calculation.
However, we often also write stuff like:
$$mO(1) = O(m),$$
or:
$$O(m) + O(n) = O(m+n) = O(\max(m,n))$$
While it intuitively describes what we mean: doing $O(1)$ work $m$ times should be in the $O(m)$ class.
I was wondering however, how correct is this notation? It seems like we are multiplying numbers with sets or adding sets - which as far as I understand isn't legitimate.
Big O notation can get a little sloppy, but it is still correct in the sense it does what you want and it can be made rigorous. One way to think of $O(f(m))$ is as the set of functions $g(m)$ such that there exists some constants $k$ and $m_0$ so that $|g(m)| \leq k|f(m)|$ for any $m \geq m_0$. In this case we often write $g(m) = O(f(m))$ or sometimes $g(m) \in O(f(m))$ thinking of it as a set. Just use which ever convention your professor does.
Lets look at your example $mO(1) = O(m)$. Here by this notation we mean $$mO(m) = \{m\cdot g : g \in O(1)\}.$$ Now take any $g \in O(1)$, then there exists $k$ and $m_0$ so that $|g(m)| \leq k$ for any $m \geq m_0$. This immediately implies that $|m\cdot g(m)| = m|g(m)| \leq km$ for any $m \geq m_0$. Thus we have that $m\cdot g\in O(m)$ for any $g \in O(1)$. Here we have shown $mO(1) \subseteq O(m)$. To really be rigorous we need to show reverse containment of these sets. We see that for any $g \in O(m)$ we have $g = m(\frac{g}{m})$ and we can show that $\frac{g}{m} \in O(1)$. Just divide both sides my $m$ in $|g(m)| \leq km$ for $m \leq m_0$ which is true since $g \in O(m)$. Thus we have the containment $O(m) \subseteq mO(1)$. Therefore it is really true that $mO(1) = O(m)$ as sets.
So, these rules are rigorous, but maybe you just did not see proofs of them. And your intuition that doing $O(1)$ work $m$ times puts you in the class $O(m)$ is accurate. As you can see above the proof of this is not really difficult, but a little long winded. Hopefully this is helpful and clears up any worries you are having.
Best,
John