what kind of villain are you facing?
some villains will not call you a raise 3x with a low pair against two players, is simply bad poker, so if you have more information about the villain`s range you could have more information
this kind of players who flat a bet with low pair against two villains (bad players) must be labeled so you can take a proper decision, because i`ve seen this move before several times and if you have labeled the villain is easier to take them but if you don`t have information then you have to pay and if lose, as you did, it was a badbeat against you,
but other players, worse than that, they simply go allin after the flop no matter if they get a set or not, they just do it because is their game, for them is recreational so they don`t care about buyins
consider this, the chances he has to hit a set in the flop are less than 15% (which doesn`t guarantee him being ahead since it could be a better set, if you have pocket queens or pocket aces, or you can hit a Q or an A in turn or river and get a full or could be a flush or a straight ), basically they are winning around 10% of time so if they are betting with a 3x raise they are losing money here
so this kind of player should be isolated as you recognize them because they are going to play like this and will give up their chips fast, but time to time they can damage your stack too,