Why add flour to grilled onions?
Fat + flour form a roux, the base for creamy/starchy soups and sauces. 

You don't give details, but Cajun recipes often let the flour/fat mixture get rather dark, which will contribute more flavour while significantly reducing the binding properties, so I suppose this is the case here, too. 

Rule of thumb: Lighter for thickening, darker for flavour.

The moment you add the liquid in your recipe, a sauce forms, which will then coat the rice and let the veggies and spices "stick" to it.