I have a background in physics and usually when you denote a set, summation or for-loop one says "for every i in N". The index is usually i and the total number of the set or population is N. Then you include a second set. You take j as the index and M as the total number in your set. In my experience these i and N, as well as j and M "belong together".
Now I'm also reading about optimisation problems in operations research and it seems as if they "connect" the letters i and M as well as j and N. Is there any convention for this?
Yes, in optimization $i$ is often used to index constraints, and $j$ for variables because the constraint matrix for a linear programming problem has one row for each constraint and once column for each variable. In linear algebra, a generic matrix has dimensions $m \times n$, with entries indexed by $(i,j)$. In mathematics, set names are often capital letters. So $M$ and $N$ are natural choices for the sets of rows/constraints and columns/variables, respectively.