The second is straightforward - to keep the same meaning you can only use with, if you use by here the meaning would be that robots came to the factory and replaced the workers with something else, physically removing and replacing the workers.
In the first only ‘by’ sounds right to me but I’m not sure why. I think it is because to say replaced ‘with’ chicken would carry the meaning that the beef was removed altogether, was substituted with chicken, whereas to say it was replaced ‘by’ implies that beef is still a popular product, although no longer the most popular.