Why does this Boolean only sometimes work?

Note that you will need to either add dog bones, or use a radius tool to relieve the edges.

or see:

That said, a better idea is to use full-blind box joints: