Every Apple device I've owned has done this (iPad, iPhone, MacBook) :/
I have one short and one long cable, and am only just now realizing the issue. I'd simply assumed the short one was a fake I'd gotten.
Can't speak to why your iPhone and iPad do the same thing, I've experienced it when using sketchy cheap lightning cables or wall adapters (including ghost touching), but not when using better built stuff (like AmazonBasics or Anker).