The problem is in 'create' method in Product class.
This method creates new list and adds a product to it. Then it assigns this list to shop.
Doing this it overrides previous list of products.
To solve this problem all we have to is changing 'create' method to following:
public static Product create(Product product,Shop shop) {
shop.products.add(product);
product.shops.add(shop);
product.save();
return product;
}