I think you're being a little hard on the writing. Remember that while Data's primary duty IS to Starfleet, he DOES break the prime directive where he sees an ethical imperative on more than just one occasion (especially in the later seasons and movies). I thought this episode showed an interesting part of Data's personality and programming-- he may be a machine, but he's not an infallible Federation puppet.