I disagree with the accepted answer. It is overly broad and not always correct.
All things being equal a link from another website will carry more weight then one from the same website. But in the real world all things are never equal. For example, if a web page on Wikipedia about greyhounds linked to the Wikipedia page about dogs, and a page on my blog also linked to that same page, the link from the other Wikipedia page would carry more weight then my link even though both pages are on the same site. This is because that page on Greyhounds has so much more weight then my page because:
- it almost certainly contains more external links pointing to it
- more valuable external links pointing to it
- more valuable internal links pointing to it
- ranks higher for the term "dogs" then my page does
I am sure there's even more to it then that. But as you can see there's a lot of factors in determining how valuable a link is. In fact a big reason why Wikipedia's pages rank so well is their internal linking. They do an outstanding job of cross linking their pages which helps to spread PR as well as "vote" for their own pages and believe me, those votes add up. A lot of web pages would rank better if their website would do a better job of cross linking their pages.
As for your question, pages from website that are related to your topic do carry more weight then links from pages that are not related to your topic. After all, links are seen as votes and a vote from a website related to your topic is seen as more authoritative then a vote from a page that has nothing to do with the topic. So if your goal is link building then you should be trying to get links from website related to your topic and rank well for the search terms you want to rank well for.