How far should the recessed lights be from 24” kitchen cabinets?
Although code is not a limiting factor the light density will be.
Based on homes I have built and redecorated I would have under cabinet lighting at the stove top, and a light above at each end shining down on the fridge and oven.
Then 2 or 3 in-line at the island. The actual spacing depends on the fixture themselves.
Some recessed lights have a narrow beam some are quite wide. I tend to split the width of the oven and fridge in this case and mount the fixture centered and 1/2 the with of the opening away from the cabinets.
With this method any openings at the bottom or top have light. If two close the bottom shelves are dark, and the cabinets reflect the light away from where it is needed. Two far away the upper shelves are dark and you have shadows when standing there looking.