A template T containing a category,
A[[Category:B]]C
is safe in that it will not destroy any paragraph breaks here,
E
{{T}}
F
when rendered. Alas, if the template is
[[Category:B]]C
or
A[[Category:B]]
it will destroy the paragraph break neighboring the [[Category:B]]!
I becomes just like if the user used E{{T}} or {{T}}F.
(I am guessing that this is some kind of overcorrection for some earlier
behavior where there was always a paragraph break rendered before and
after [[Category:B]].)
Anyway the user now has no way to preserve his paragraph breaks, short
of having to use raw <p>'s:
E
<p></p>
{{T}}
<p></p>
F
(Why would anyone want to use such a template?
Well, to add a category to a page at the same time making a note on it.)
The user might want to use his template in all kinds of different
whitespace / paragraph break environments.
V {{T}}
W{{T}}X {{T}}Z
**Mediawiki should never disturb (eat or add) any whitespace or paragraph
breaks when inserting templates containing categories.** (Or even if they don't contain categories, for that matter.)
(I did not test the case where there was no A or C. Please do. (Why
would someone make such a template with no A, C text at all? Well, e.g.,
T=[[Category:Bugs to be fixed by 2019]] so one could just adjust the
date of T instead of editing each page where {{T}} was used.))