The function std::string::compare() returns an int:
equal to zero if s and t are equal, less than zero if s is less than t, greater than zero if s is greater than t.
If you want your first code snippet to be equivalent to the second, it should be written as follows:
if (!s.compare(t)) {
// 's' and 't' are equal.
}
The equality operator merely checks for equality and returns a bool.
To expand on the use cases, compare() might be handy if you're curious about how two strings relate to one another (less or greater) when they're different.
PlasmaHH mentions trees correctly, but it might also be a string insertion technique aimed at keeping the container sorted, a dichotomic search method for the aforementioned container, and so on.