-을 after time duration usually gives a sense that this time duration is a fresh topic that is being brought up. I don't consider this -을 to be object marker.
For instance, if someone asked you about how long you've been living in Korea, then you would usually say: 2년 살았어 or 2년동안 살았어. It's without -을 with time duration because the duration was the topic of the conversation when you answered. However, if it's you who wants to start talking about the time duration, you can say 내가 한국에서 2년을 살았어.
Or, you can also use it to make emphasis on the time duration.
내가 3년을 공부했어 can sound like you're emphasizing on how long you've studied it.
Like in other languages, an emphasis can be used for various reasons in different contexts. This may mean that you've had up with it, or just boasting it etc..