Irony can be a tricky, somewhat head-spinning word. It’s a word that can be used often but seldom clearly defined. A general definition of irony entails countering perceived expectations or norms in a way that's humorous or generally amusing.
Concerning the Bazarov excerpt in the question, the irony might relate to the similarity between Bazarov’s adoration of Anna Sergeyevna and Pavel’s infatuation with Princess R. The story sets up Bazarov and Pavel as opposites. They do not like one another. Bazarov disdains Pavel’s proud, military virtues. Pavel, meanwhile, scorns Bazarov’s brash, nihilistic style.
It might be ironic—in other words, extremely contrary to expectations—that, for all of the enmity and supposed differences between Bazarov and Pavel, Bazarov still follows in Pavel’s footsteps. Like Pavel, Bazarov is an avowedly self-assured, self-possessed man who can’t help but yield his imputed power to a strong, independent woman.
In the passage noted in the question, the narrator writes that Bazarov would walk in the woods and curse himself for his inability to resist Anna Sergeyevna. Taking into account Pavel’s past situation and its resemblance to Bazarov’s current predicament, it might be argued that Bazarov is also cursing his failure to resist the irony of winding up like someone he is supposed to despise and not be like at all.