Take s = "racecar". At index (the character "e"), you expand outward: left goes to index ("c"), right goes to index ("c"). They match. Keep going: index ("a") and index ("a") match. Then index ("r") and index ("r") match. You've found "racecar" with length .
No other center produces a longer palindrome, so "racecar" is the result.
Time: . You visit centers and each expansion can go up to steps. Space: . You only store pointers and the best start/length found so far.