From A Measure of A Man (S2E9), under orders, Riker argues that Data is a machine, and thus does not deserve human rights. Earlier in the episode, Captaiin Louvois (the officer acting as judge here) summarily rules that Data is a machine and is the property of Starfleet. Picard challenges that ruling. Since Louvois doesn't have any staff aboard the Enterprise, Starfleet regulations mandate that Picard and Riker act as opposing attorneys. Riker refuses because he sees Data as a true friend. Louvois explains that this is the only way her ruling can be challenged, and that if she suspects Riker is throwing the case, she can stop the proceedings and her initial decision will stand. So Riker reluctantly agrees to aggressively prosecute his friend.