Toothpaste contains fluoride which can hurt the stomach when it accidentally gets into your stomach even though didn't mean to swallow some.
Sometimes you might swallow just a tiny bit of the toothpaste without realizing it and then when that toothpaste gets into your stomach the fluoride then causes the stomach to hurt.
It's usually nothing to worry about though and just drinking some tea or water can help settle the stomach.
If you swallow too much toothpaste then it could be deadly but just swallowing a tiny bit of toothpaste should not do any harm.