They don't actually overlap -- they're just touching. You'd see the same behavior in other places if you had buttons that wrap to multiple lines.
But generally speaking, there isn't really an expectation of wrapping in a situation like this. Normally you'd collapse the buttons down so that you don't take up so much space with them. If that's not an option, you may need to take specific action to ensure that there are margins/spacing that fit your needs.