Of course it's possible, but I think the probability is greatly reduced.
I was a straight A pupil at the end of primary, but left secondary school 5 years later without a single O level!
That was due to a general malaise amongst many teachers, high staff sickness/absence rates and persistent bullying. I attended every single day and every single lesson, but the whole place wasn't a suitable learning environment. Teachers would set homework, I'd do it, but it wasn't marked, so I'd stop doing it as there was no point!
Once I left, I did a mix of evening classes at the local college and self-teaching, alongside a full time job, to get my O levels, then A levels and eventually my chartered accountancy qualifications, so I wasn't "thick" or unmotivated. It was simply being stuck in a crap comp for 5 years!
Having said all, I had a friend who was a neighbour, same age, same primary school, same secondary school, who was similar ability to me at primary, who flew at the same comp and got a string of top grades. But, different forms, different sets, different teachers, different friends, etc. Sometimes, it really is just luck of the draw as to which teachers you get, whether the bullies are in your form, etc.