A triangle is defined as a closed shape bounded by three and only three line segement.
In the above diagram (a) and (b) both have three sides but (b) is a triangle and (a) is not a triangle.
The reason is (b) is a closed shape and (a) is an open shape.
Thus, a closed shape is a triangle if and only if it has three sides.