As an American, the answer for countries is the US. However, in just a few short years, I will have spent more than 50% of my life in Thailand.
For least, that would be a toss-up between France, Luxembourg and Liechtenstein. I was hitchhiking in Europe, and a British truck driver gave me a lift on the edge of Brussels and took me all the way to Switzerland. We passed through Luxembourg and the northeastern part of France – I remember we drove through Nancy – before he let me off in Basel, Switzerland.
Then later in that trip I think I passed through those countries again on an overnight train from Germany to Brussels, thus giving Liechtenstein the win, because I passed through there on a train from Zurich to Vienna and never went back through, so I’m pretty sure Liechtenstein was a shorter period. (Also, while flying from Mexico City to Managua, my flight made brief stops both ways at the airports in the capitals of Guatemala and El Salvador, so those might win, but at least with Liechtenstein I traveled the breadth of the country down on land.)
As for countries I’ve actually stayed in, that would probably be Taiwan. Twice I’ve had to stay overnight in the airport hotel on my way to the US, and the last time the airport hotel had been moved a few blocks away, so I had to be stamped into the country. Macau might be a contender, as I made an overnight trip there once from Hong Kong, but the number of hours I spent in Macau might exceed my total amount of time in Taiwan, not sure. And Macau was still a Portuguese colony then and has never been a country.
Now for US states. The most time, unfortunately, is Texas, having lived there for 24 years, from ages 5-29.
For least amount of time, that would probably be Delaware, as we passed through there while taking the train from Washington to New York. On that same trip, we also passed through New Jersey twice by train and Maryland once by train and once by car. But Delaware just the once, and that was really brief. Once the wife and I popped up into Missouri while driving around northern Arkansas and was there for an hour or two, maybe. I still think Delaware has it. Close though.
If you count airport stops, then Washington state would win, because back when Thai Airways still flew from Bangkok to Dallas, the plane stopped for an hour in Seattle.
For states I’ve actually stayed in, that would be a toss-up between Louisiana and Kansas. On family trips as a boy, we stayed overnight once in Shreveport on our way from Texas to Arkansas and on another trip overnight somewhere in Kansas on our way from Texas or Oklahoma (I think we had stayed with some friends in Oklahoma City on that trip) to Colorado.