Just because the prosecution has an eyewitness for your alleged crimes doesn't mean that you have already lost the case. Eyewitness testimony is not infallible, which means you may be able to defend yourself even with eyewitness testimony. Below are some of the reasons eyewitness testimony is not always watertight.
Stress
Many people get stress if they witness a crime in progress. This is especially true in cases of violent crimes. For example, watching a robber shoot their victim can be extremely stressful. The stress can mess up the eyewitness' memory and lead to flawed testimony.
Different Focus
For criminal actions that involve weapons, many people focus more on the weapon than the criminal. For example, if someone attacks someone else with a knife, the eyewitnesses are likely to remember more details of the knife than the attacker. As a result, identifying the attacker can be quite difficult.
Cross-Racial Issues
There is evidence that many people can easily identify people of their race but not of other races. This means if the alleged criminal is of a different race from the eyewitness, then the identification process will be more flawed than if the two had been of the same race.
External Influence
Many witnesses get to the courtroom after they have been bombarded with information about a crime from different sources. For example, if someone watched a convenience store robbery, they may read about the robbery online, see news clips of the robbery on television. Such news sources might contain inaccurate information about the crime, but the eyewitness might internalize the errors (even unconsciously) and relay the same information during testimony.
Pressure
Eyewitnesses are usually under a lot of pressure to produce relevant or helpful information during the trial. The pressure can come from different sources such as the prosecution or the victims of the crime. Many people inevitably make mistakes when faced with such pressure. Some people even make up testimony when under such pressure.
Multiple Suspects
If a crime is committed with more than one person, it becomes difficult for eyewitnesses to remember the suspects. For example, a shopper who witnesses a lone gunman rob a store is likely to remember the gunman than a shopper who witnesses three gunmen commit a similar crime.
As you can see, you should not despair with your defense just because an eyewitness is testifying against you. Consult a criminal defense lawyer to help you with the defense; the lawyer may even succeed in discrediting the eyewitness' testimony.