When you purchase a capital asset, you need to estimate what its useful life will be. The key word, here, is estimate. You don’t know at the outset what will happen… what will turn out to be a lemon, what will break, or what will (amazingly) last years longer than you anticipated. You also don’t know what advances will come along, that may make it more economical to replace something early than to use it ‘till it wears out.
If you discard something earlier than expected, then the year of disposal must take all remaining undepreciated cost.
This makes sense: the mechanism of depreciation is intended to spread the cost of an asset fairly over the years of ownership. If you dispose of an item early, then your accounting records must show that the asset is gone. The only way to do this is to take the expense.
Managing the journal entries around discarding capital assets is a good topic of discussion with your accountant. You need to follow your organization’s accounting policies, and make sure you’re recognizing the expense correctly.