There are important items to address here.
1. Creating new figures
if mod(n,10) == 0
figure('WindowState','maximized');
end
This section of your code creates a new figure every 10 iterations of your for-loop and then new axis tiles are added to the new figure. If you remove this, then all axis tiles will be added to the same figure resuling in all 50 axes added to the same figure.
If your goal is to merely use the default figure size, then change this to
if mod(n,10) == 0
figure();
end
2. Flow layout
You aren't specifying the intended layout of your axes. You mention that there is a 5x2 layout but if you make the figure very narrow then the tiles will refactor into a 10x1 layout. If you want a specific 5x2 layout, specify the grid size by calling this after creating the figure
but if you'd rather keep the flow arrangement, then you can use the line below. Just know that the layout might not be 5x2 - it will depend on the figure size, among other factors.
3. How nexttile works
nexttile addes a new tile (axes) to a tiledChartLayout which is the object created by tiledlayout. It's recommended to explicitly define the tiledlayout using one of the lines above so that people reading your code (including your future self) can more easily identify what is going on. If you call nexttile without defining a tiledChartLayout, then it the layout will default to flow.