The p-value should be considered between a CI and a meanparameter value, not two CIs. Indeed, the red point falls entirely outside the blue CI, and the blue point falls entirely outside the red CI.
And it is true that under the null hypothesis such an event would happen 5% of the time:
- 2.5% of the time, you get a point above the 95% CI
- 2.5% of the time, you get a point below the 95% CI
If it is only the whiskers that overlap or touch, then the null hypothesis will produce this result a lot less often than 5%. This is because (to use your example) both the blue population meansample would need to be highlow, and at the same time the red population meansample would need to be lowhigh (exactly how lowhigh would depend on the blue value). You can picture it as a 3D multivariate Gaussian plot, with no skew since the two errors are independent of one another:
Along each axis the probability of falling outside the highlighted region (the CI) is 0.05. But the total probabilities of the blue and pink areas, which gives you P of the two CIs barely touching, is less than 0.05 in your case.
A change of variables from the blue/red axes to the green one will let you integrate this volume using a univariate rather than multivariate Gaussian, and the new variance is the pooled variance from @Sextus-Empiricus's answer.