There isn't any measured distance, so they could be right next to each other. You just need to ensure that the panel has all of the required working and dedicated space distances outlined in Article 110.
Like all urban legends, it probably originated from something that was true, and then evolved into something that is not true. For example, there is a rule that mentions receptacles, sinks, and 6 feet. Perhaps that is the one that became the basis for the belief that you can't have panels near sinks.