When you have a “gut feeling” it’s the subconscious part of your brain triggering a mild fight or flight response. This happens when the always watching and listening subconscious part of your brain notices something that the conscious part of the brain was too distracted to notice. The hypothalamus then signals your adrenal glands to release adrenaline to give your body some extra strength, so that you can either run faster or fight harder.
Among other things, adrenaline will cause your bowels to contract and your blood vessels to expand. This is what that stomach sensation basically is and why some people will literally sh*t themselves during a high-stress situation.
It is also worthwhile to point out that the gut feeling can be sometimes completely wrong and you can see extreme examples of this in people with anxiety disorders, who experience way more “false positive” alarms.