This is based on the GI of the foods. The glycemic index (GI) rates carbohydrate foods on how quickly blood sugar / glucose levels increase in the 2 - 3 hours after eating as the carbs are converted into glucose. Generally fat or protein doesn’t increase glucose levels.
Eating higher GI foods produces a rapid increase in blood glucose levels, triggering the pancreas to produce insulin. Insulin causes the body’s muscle and liver cells to attempt to store the excess glucose. Imagine insulin as a shuttle, moving glucose from just digested foods into storage. If the digestive system is pumping glucose into the blood stream quicker than insulin can move it into the muscles / liver or glucose stays high too long, the body will convert the excess glucose into fat.
Eating lower GI foods produces slower glucose raise, little insulin and fat storage, even if you have eaten high fat content foods!