This sounds like the known problem of overlapping manual and automatic pit activation. On your client UI you activate pit as it hasn't received the automatic pit activation yet but on the server the automatically activated pit is cancelled by the manual input.
Is there a planned fix for this? This happened to both my cars tonight, one retiring.
I saw a comment on another post how you can just wait for the automatic pit. However, in my experience this is always a gamble because there have been times when my car didn't come in when expected (e.g. when it's possible to do most of another lap).