Welcome to the Shopify Community! Great question, in order to offer a customer both a buy X get Y discount, as well as a free shipping discount code, you will likely require the use of an app. This is because it is not possible to stack discounts through the Shopify admin, meaning customers can only use one discount code per order. Below are a few app options for you that will allow your customers to use more than one discount code in an order:
Alternatively, you could setup a free shipping rate in your Shipping and Delivery settings. This would apply to all orders that meet the criteria you set. Then, customers can use a discount code, and still receive free shipping as the free shipping rate would not be setup through the Discounts section of your admin.
Let me know how this goes, and if you have any questions!