Star Trek: First Contact is among the greatest stories ever told in the world of Trek. Be it film, book, show, or other, First Contact remains a brilliantly told story in the world of Star Trek. While there are many, many reasons why that is (and we talk about them endlessly here), one of the more impressive, but least talked about aspects of the film is the journey through humanity that Data goes through.
Paired with a computer chip that allows him to feel genuine human emotions, Data can now experience the same feelings your ordinary human can. It allows Data to get closer to his dream of being more human. But it also allows Data to become fallible. One of the aspects that made Data so interesting is that he was purely logic-based, and while his desire to be more human may have mirrored that of Spock to a degree, Data had no influence to his programming the way Spock's Vulcan and human side seemed to have.
So Data was largely always on the right side of the situation unless he didn't understand the nuances of a complex emotional situation. Until First Contact. Now able to feel emotions, the Borg Queen, the movie's villain, is able to dangle things in front of Data that he thought otherwise unobtainable, like humanity. Not only would he have human emotions but with the help of the Borg Queen, he could have synthetic skin, that allowed him to feel for the first time the way a person would. A tactile connection was once thought impossible.
So impossible, that the Borg Queen is actually able to seduce him romantically, and for a time, even caused Data to question his allegiance to Jean-Luc Picard and the U.S.S. Enterprise. The fact, that Data doubted what to do, was the ultimate sign of him reaching humanity. Insecurity and confusion are hallmarks of the human experience and being preyed upon by someone looking to manipulate you is something we've all dealt with.
It wasn't something that Data dealt with to this degree; not with so many variables mucking up the logic of the situation. It made it so hard for Data to realize what was right, that it truly made him human in that moment. This is why it was the most logical thing to happen for him, because you can't really say you had a human experience without saying someone tried to manipulate you. As sad as that may sound.