Big O analysis trying to follow a logic
Possibly it's not for each $n$, but for each $i$.

First, try to calculate $m$ for each specific $i$:

 i | m
-------
 1 | 3
 2 | 5
 3 | 7
 4 | 9
   :
 n | 2n+1


$m$ increased by two for each loop of for i = 1 to n. Therefore $m = 2i+1$ for each $i$ in the loop.

And this is repeated from $i = 1$ to $i = n$, so in total,

$$
  \sum_{i=1}^n (2i + 1) = n^2 + 2n
$$