Do foreigners legally have to carry ID?

You mean in penghu/kinmen, Matsu you don’t need to carry but on taiwan proper you need to ?

FYI, referring to China as mainland when discussing china/Taiwan makes as much sense as calling China mainland when discussing Japan/China

Not even in hk which arguably is part of China do people call China mainland(other than gov), China is China.