When you cancel an order, you will be given the choice whether you want to return the inventory or not.
The moment you change the order status to "canceled" or delete an order, you will see a pop-up appear in the display with the question whether you want to restore the ordered products from the order to the stock. You then have the opportunity to answer "yes" or "no" here.
Please note! Removing an order is not recommended at all times. A canceled order is also an order that must be processed in the administration.