If a judge decides that the police lacked probable cause at the time of the arrest, that does not always mean that the defendant is in the clear. By the time a judge makes that decision, the police may have gathered enough additional and independent information to have probable cause. If so, a defendant might be released, only to be immediately and properly rearrested based on the additional information.
The reason for this result has to do with the reason for requiring probable cause: To make sure that arrests are made for good, solid reasons. If some of those reasons were unknown at the time, but become known later, a judge may reason that the ensuing arrest is valid because no purpose would be served by invalidating it. On the other hand, the practice would seem to encourage the police to try to obtain warrants on scant probable cause, hoping that, if challenged successfully, they will have independently garnered enough evidence in the meantime to adequately establish probable cause for a second warrant.
To learn more about probable cause and arrests, see What Is an Arrest?