On mobile I don’t see the behavior in editing view (but I do in reading view).
In original Markdown inline code spans in Markdown aren’t intended to be marked as pre-formatted. Block is marked with <pre> and <code>: Daring Fireball: Markdown Syntax Documentation, inline is marked with only <code>: Daring Fireball: Markdown Syntax Documentation. The CommonMark spec, which Obsidian largely follows, uses that same markup but says whitespace should not be collapsed and recommends the CSS suggested by OP. CommonMark Spec