Helping people with computers... one answer at a time.
There are assorted ways that an IP address might be linked to or associated with an illegal or malicious web site. I'll look at some of the scenarios.
Can my IP address be linked to an illegal site without my knowledge?
It really depends on what you mean by "linked to".
If you mean "identified as a visitor to that site?" then there definitely are scenarios that you need to be careful of.
If you mean "identified as the site", meaning your IP is somehow identified as being the illegal site, or hosting that illegal site's contents ... well, believe it or not there are some scenarios there too.
The good news is regardless of what you mean, there's a common villain.
By far the easiest way for either meaning to happen is malware.
Let's say you have malware of some sort on your machine that turns it into what's called a proxy. That means that some other person could use that malware to connect to the illegal site through your machine.
The malicious use configures his browser to route all of his internet access through your machine. That means that whatever site he's accessing "looks like" it's being accessed by your machine.
If he accesses an illegal site, then it's your machine that then connects to the illegal machine on their behalf.
And of course that would make it look like the machine at your IP address had accessed the illegal site.
This time we'll say you have malware on your machine that turns it into a "pass through web server", or gateway.
This is similar to a proxy, in that people access your machine to get at the illegal content and your machine is the one that connects to the illegal site.
In the gateway scenario the malware implements a kind of web server that simply passes through all the requests and responses to and from an illegal site. Anyone who accesses, say, http://your.ip.address, would get the content from the illegal site as your machine acts as a pass-through gateway.
In this scenario, not only is your machine (and IP address) accessing the illegal site to fetch the content to be passed through, but it also looks like it's hosting the site, since the requests for the illegal content are being made of your machine (at your IP address) and your machine it returning that content - even though it had to go elsewhere to get it.
In this scenario the malware actually copies some or all of the content from the illegal web site to your machine (or carries with it that content that is then placed on your machine when infected). The malware then sets up a fairly simple web server on your machine that then serves up the illegal content.
In this scenario it looks like your machine (at your IP) is hosting the illegal content - because it is.
When you visit a web site it may load its contents from several other web sites.
A good example is Ask Leo!. While you visit http://ask-leo.com to view the articles, many pieces are coming from completely different sites and servers. The logo image, for example, comes from http://img.askleomedia.com/.
In that same way you could visit a site that pulls some of its content from the illegal site, and it would appear as your machine and IP address requesting that content.
More often than not this can happen when the site you're visiting has itself been compromised and malicious pages or software installed on it.
As you can guess, all of the above can happen without your knowledge if you've allowed your machine to become infected with malware.
Unfortunately the simply platitude - "so, just don't get infected with malware" - is more complex than it sounds. The standard litany of internet security applies:
Use a firewall
Use anti-malware software
Keep your system up to date
Keep the anti-malware software up-to-date
Don't invite malware onto your machine by downloading or opening things you're not certain of
There's a more complete list in my article Internet Safety: How do I keep my computer safe on the internet?
The most common scenario where your computer or IP address might show up as having accessed an illegal web site - or any website you didn't access yourself, is someone else.
Someone else used your computer while you weren't watching
Someone else connected to the same router as you appears on the internet as the same IP as you (quite common, actually, if your WiFi is not protected with a password)
Bottom line: keep your machine and internet connection secure - both in terms of software, and who you allow to access them.