I've recently received some recommendations on LinkedIn from my previous bosses and coworkers. I explicitly asked them to write one. Should I now ask them if they want me to write a recommendation 'in exchange'? I am worried that they might have done this because thay are kind and might not want my recommendation on their profile. What's the best way to ask or determine if I should write such recomendations in some diplomatic way?
You are overanalyzing a non-issue. If you want to write a recommendation, then you write it. If you don't want to write one, then you don't write it. There is no diplomatic way of asking anyone, "should I write you a recommendation?" No matter how you phrase it, it would be perceived as one or more of silly, rude, patronizing, or naive.
I cannot think of any reason why anyone wouldn't want a recommendation from one of their direct subordinates or coworkers (unless of course, the "recommendation" is of the "my boss/coworker was a complete idiot" type). In any case, if they don't want your recommendation on their profile, they can simply decline it or even remove it later if they change their mind.
If you want to write a recommendation as a professional courtesy in exchange for the recommendation they wrote you, then just write one and be done with it. Let them figure it out whether it is good enough for their profile or not. Be aware that there's also an option to ask the recommender to edit the recommendation, but I don't expect people to use it often.
There is nothing to stop you asking people if they want you to provide a recommendation for them, though some might be surprised you are asking as it is not a common enquiry in my experience.
However I believe that anyone looking at a profile and seeing that there are reciprocal good recommendations between two people would dismiss them both as having little value. I actively discourage reciprocal recommendations on my profile (and explain why to those that seek them).
My point is that someone who sees a reciprocal recommendation would perhaps not stop to work out whether they have value, but would assume that one or both were given only in response to an incoming recommendation irrespective of whether they are accurate and informative. This would defeat the object of Recommendations.