This phrase is often used sarcastically to mock someone's credulity. He claimed he'd been to Mars. If you believe that, you'll believe anything.
Pro Tip 2/3
Not Literal
It's not meant to be taken literally; it exaggerates to make a point. She says she knows the president personally. If you believe that, you’ll believe anything.
Pro Tip 3/3
Colloquialism
The phrase is informal and best used in casual conversation, not formal writing. He's promised not to be late again—if you believe that, you'll believe anything!