The thing is, it’s not really a physics problem, it’s a computing one – you balance by steering the bike back under your centre of gravity. The way your brain analyses pretty sparse data to create a feedback system to keep you upright, without you thinking about it, is pretty astounding.
There are some things that physics and maths can help with – with why some bikes are more stable than others, with how self-centering steering helps with the feedback system, with how the vertical movement as you steer can lead to “flop” or stability.
Over the years, people have tried to build “unrideable” bikes – ones with tiny wheels, ones with counter-rotating gyroscopes, ones with steering at the back or in the middle. Some take a while to learn to ride, but people get the hang of them eventually.