If you are prosecuted for a crime and found innocent the government doesn't pay your legal fees, ever. There is no cause of action in a criminal trial for compensation for costs by the defendant. These types of damages are only awarded in civil cases.
You have to bring a separate civil suit against the government for compensation. It's the whole criminal vs. civil trial thing - a criminal trial is one the state brings to you with you being free (not guilty) or jailed (guilty). A civil trial outcome is usually just monetary to make whole.
As we believe jailing an innocent is very bad, that's why a criminal trial standard is "beyond a reasonable doubt" whereas a civil trial is either "preponderance of evidence" or "reasonable belief" (basically who made the more convincing argument)
But it's perfectly fine to bring a civil trial to get damages caused by a criminal trial. It's how OJ Simpson was both guilty and not-guilty.