However, he knew that if he smashed it, the bell would make a loud noise and attract attention. He reasoned that if he covered his ears, nobody would be able to hear the bell ring. He covered his ears, but as soon as he touched the bell, it rang and he was caught.
This idiom refers to people who believe they are clever, but in fact are only tricking themselves.
Read more about the idiom here.