It depends to a large degree on local employment laws. Depending on how the counteroffer was worded, it might have constituted anything from a binding legal contract for employment for some reasonable minimum term, or a totally non-binding suggestion that was worth less than the air breathed while pronouncing it. Some things to consider would include:
What are local employment laws like? Do they require that termination be for cause? If so, what are causes for termination? Does termination require any kind of remediation beforehand? Note that in an at-will, right-to-work state in the US, odds are that the employee can be fired for any time and for any reason, supposing the employer hasn't accidentally entered into a contract by extending the counteroffer.
What did the counteroffer say? Did it stipulate that the offer was not for a definite term and that the company reserved the right to terminate the employee for any reason, or no reason at all? Odds are any sufficiently serious business in an at- will, right-to-work state would use standard legal language in any offer or counteroffer to ensure that they are on the right side of this, so odds are the counteroffer was accepted with no obligations at all on the company.
Does the termination affect eligibility for unemployment benefits? I would say most likely not, as the termination would probably be recorded as being for no reason legally speaking (if they admitted to terminating the employee for seeking other employment, interested government officials could take a dim view of the company's actions). You'd probably have at least some unemployment compensation coming your way.
Some professional - not legal - advice. Never accept a counteroffer. Only get another offer in the first place if you are committed to leaving your current employer no matter what. If your company really insists, you should insist on a minimum definite term of employment written into a legal contract which is signed by an executive and notarized. No company will agree to this (unless the term is shorter than you'd want as a full-time W-2 anyway) but if they do, hey, you have some security (if the company agrees to this, have your own lawyer - whom you pay with your own money - review the document). Even then, I would be very, very careful about staying at a company after getting a counteroffer. Don't do it. Ever. Never accept a counteroffer.
One comment asks why I recommend never accepting a counteroffer. There are at least two reasons:
The reason you are looking for a new job should be that there is something about your current job that isn't completely satisfactory and that you haven't been able to fix. Either you have grown out of the position, don't like the work, feel you're underpaid, don't get along with somebody, etc. If you were unable or unwilling to fix any of these issues without having another job on the table, having another job on the table shouldn't be what makes you willing and able to fix them. Why work somewhere that you'd constantly need to go job hunting to address workplace issues?
Unless the company makes firm agreements about how long they're going to keep you around, you have no guarantee that they'll keep you. Presumably, you didn't have one before, and you don't have one at the new job, but the fact that you are currently employed might support the assumption that your employment would be continued at your current employer and the offer might support the assumption the new employer plans to employ you indefinitely. When you put in your notice, it makes the company more aware of the fact that you could leave at any time; while a perfectly rational actor would realize that this doesn't change the situation at all, companies are run by people and people often act irrationally. Perhaps your manager is vindictive, perhaps your manager is scared that you will still leave after accepting the counteroffer. Maybe your manager knows there are layoffs coming but needs you for the busy season. Hiring replacements can be time-consuming and expensive - and employees who are getting offers of employment elsewhere and putting in notice might be seen as risks.
I'm not saying that accepting a counteroffer has always turned out badly. Falling coconuts kill 150 people every year. Still, I am not going to add a coconut rider to my insurance policy and I am not going to accept a counteroffer.