

It works if you believe your religion. If you are a roman swearing by Jupiter you are asking Jupiter to strike you with lightening if you lie - and as a believer you honestly think that will happen. since most people are christians they swear on the bible knowing they are asking to go to hell if they lie - even if otherwise they are good enough to be forgiven. Muslins generally swear of the quarn - to similar reasons (i’m not clear on what muslins believe happens if they lie, but they believe in it which matters)
of course a large number of people are not religious these days - so this is often pointless.


https://acoup.blog/2019/06/28/collections-oaths-how-do-they-work/ has a very interesting discussion and you should read it all. Not everything applies to modern world but the majority does