Yes it's illegal to put something on the outside of your mailbox.
If you were to tape flyers or put something else on the outside of someone's mailbox then you could get into trouble and get a fine for tampering with a mailbox.
You should never put anything into someone's mailbox unless you're a mail carrier and delivering mail to that person.
However you can legally put flyers in through a door slot where someone gets their mail as the USPS does not regulate those door slots.
But the USPS does regulate and control your curbside mailbox.
Although technically you still own your curbside mailbox the USPS has authority over it and can get someone into trouble for destroying it, tampering with it etc.
So never place anything on someone's mailbox or you risk a fine.